// 参考：<https://morris821028.github.io/2014/12/02/uva-1674/>
#include <bits/stdc++.h>
using namespace std;
const int N = 65536;
int visited[N];

// 并查集部分
int parent[N], setrank[N];

// 路径压缩 O(1)走起
int findp(int x) { return parent[x] == x ? x : (parent[x] = findp(parent[x])); }
int joint(int x, int y) {
  x = findp(x), y = findp(y);
  // 同一棵树上
  if (x == y) return 0;
  // x树比y树的秩大，将y树合并到x树上
  else if (setrank[x] > setrank[y])
    setrank[x] += setrank[y], parent[y] = x;
  // y树比x树的秩大，将x树合并到y树上
  else
    setrank[y] += setrank[x], parent[x] = y;
  return 1;
}

// LCA部分
vector<int> tree[N];              // 邻接图定义的树
vector<pair<int, int>> query[N];  // query 询问，<index, node>
int LCA[N];                       // 每次询问的两个点的LCA

/**
 * @brief tarjan算法是一种**离线算法**
 * 使用并查集记录某个节点的祖先节点
 * 在回溯过程中处理询问
 *
 * @param u 当前节点
 * @param p u节点的祖先节点
 */
void tarjan(int u, int p) {
  // 进行一次DFS遍历
  parent[u] = u;
  for (int i = 0; i < tree[u].size(); ++i) {
    int v = tree[u][i];
    if (v == p) continue;
    tarjan(v, u);
    // 记录当前节点的父节点
    parent[findp(v)] = u;
  }
  // 记录visited情况
  visited[u] = 1;
  // 回溯，以该节点为起点当遍历到某个节点时，认为根节点是其本身，
  // 对有关该节点的所有询问
  for (auto x : query[u]) {
    auto idx = x.first;
    auto node = x.second;
    // 如果已经访问过了，那么就是u节点的儿子
    if (visited[node]) {
      LCA[idx] = findp(node);
    }
  }
}

int childrenWeight[N],  // 子树（不包含根节点）权重之和
    rootWeight[N];      // 本节点权重之和

// 使用DFS统计权重
int dfs(int u, int p, int childrenWeight[]) {
  int sum = childrenWeight[u];
  for (auto v : tree[u]) {
    if (v == p) continue;
    sum += dfs(v, u, childrenWeight);
  }
  return childrenWeight[u] = sum;
}
int X[N], Y[N], K[N];
int main() {
  int n, m, x, y;
  int testcase;
  cin >> testcase;
  for (int cases = 1; cases <= testcase; ++cases) {
    cin >> n;
    for (int i = 0; i < n; ++i) tree[i].clear();
    for (int i = 1; i < n; ++i) {
      cin >> x >> y;
      tree[x].push_back(y);
      tree[y].push_back(x);
    }
    memset(childrenWeight, 0, sizeof(childrenWeight));
    memset(rootWeight, 0, sizeof rootWeight);
    memset(X, 0, sizeof(X));
    memset(Y, 0, sizeof(Y));
    memset(K, 0, sizeof(K));
    for (int i = 0; i < n; ++i) {
      visited[i] = 0, query[i].clear();
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
      cin >> X[i] >> Y[i] >> K[i];
      query[X[i]].emplace_back(i, Y[i]);
      query[Y[i]].emplace_back(i, X[i]);
    }

    // tarjan 法求LCA
    tarjan(0, -1);

    // 对每次雷击，都是给节点的子树增加K[i]，给节点减去K[i]
    for (int i = 0; i < m; ++i) {
      rootWeight[LCA[i]] += K[i];
      childrenWeight[X[i]] += K[i];
      childrenWeight[Y[i]] += K[i];
      childrenWeight[LCA[i]] -= 2 * K[i];
    }

    // dfs 统计电量
    dfs(0, -1, childrenWeight);

    printf("Case #%d:\n", cases);
    for (int i = 0; i < n; ++i)
      printf("%d\n", childrenWeight[i] + rootWeight[i]);
  }
}
